import java.util.*;

public class Test {
    public static void main(String[] args) {
        Set<Integer> set=new TreeSet();
        //1.插入-add
        for(int i=10;i>=0;i--){
            set.add(i);
        }
        //2.判断元素是否存在-contains
        System.out.println(set.contains(5));
        //3.移除元素-remove
        System.out.println(set.remove(10));
        //4.获取迭代器-iterator
        Iterator<Integer> it=set.iterator();
        while(it.hasNext()) {
            System.out.print(it.next() + " ");
        }
        //5.去重-addAll
        Set<String> s=new TreeSet();
        s.addAll(new ArrayList<>(Arrays.asList("a","d","c","a")));
        System.out.println(s);



    }
    public static void main1(String[] args) {
        Map<String,Integer> hash=new TreeMap<>();

        Map<String,Integer> e=new HashMap<>();

        hash.put("刘备",1);
        hash.put("张飞",3);
        hash.put("关羽",2);


        Set<String> s=hash.keySet();
        System.out.println(s);

        Set<Map.Entry<String,Integer>> tmp=hash.entrySet();
        for(Map.Entry<String,Integer> x:tmp){
            if(x.getValue()!=1){
                x.setValue(1);
            }
        }
        for(Map.Entry<String,Integer> x:tmp){
            System.out.print(x+" ");
        }
    }
}
